<template>
  <div class="app-main-container">
    <div class="app-main-title">{{ $t('message.rlfx') }}</div>
    <div class="doumee-filter" style="width: 100%">
      <el-select v-model="checkedStatus" :="$t('message.qxz') + $t('message.bblx')">
        <el-option :label="$t('message.rbb')" value="1" />
        <el-option :label="$t('message.ybb')" value="4" />
        <el-option :label="$t('message.nbb')" value="6" />
      </el-select>
      <el-date-picker
        v-model="date"
        type="date"
        :placeholder="$t('message.xzrq')"
        value-format="yyyy-MM-dd"
        :clearable="false"
      />
      <el-button v-preventReClick type="primary" @click="search">{{ $t('message.cz') }}</el-button>
      <!-- <el-button v-preventReClick @click="clear">{{ $t('message.clear') }}</el-button> -->
      <el-button v-preventReClick type="primary" @click="$router.push({ name: 'Devicjs' })">{{ $t('message.tbiao') }}</el-button>
    </div>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      :header-row-class-name="'table-header'"
      class="doumee-element-table"
    >
      <el-table-column align="center" :label="$t('message.sbmc')" prop="equipmentName" min-width="200" />
      <el-table-column align="center" :label="$t('message.sbbm2')" prop="equipmentId" min-width="300" />
      <el-table-column align="center" :label="$t('message.time')" prop="time" min-width="200" />
      <el-table-column align="center" :label="$t('message.jczsrc')" prop="totlEntries" min-width="100" />
      <el-table-column align="center" :label="$t('message.cczsrc')" prop="totlOut" min-width="100" />
    </el-table>
    <div class="flex-cc doumee-pagination">
      <el-pagination
        background
        hide-on-single-page
        layout="prev, pager, next"
        :current-page.sync="page"
        :total="totalCount"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script>
import { crowdedAllCount } from '@/api'
import { parseTime } from '@/utils'
export default {
  name: 'Devicej',
  data() {
    return {
      current: 1,
      page: 1,
      totalCount: 10,
      list: [
      ],
      listLoading: true,
      date: parseTime(new Date(), '{yyyy}-{mm}-{dd}'),
      checkedStatus: '1'
    }
  },
  created() {
    this.listLoading = false
    this.getCrowdList()
  },
  methods: {
    selectStartTime(v) {
      console.log(v)
      this.startTime = v + ':00'
    },
    selectEndTime(v) {
      console.log(v)
      this.endTime = v + ':00'
    },
    handleCurrentChange(val) {
      // console.log(`当前页:`, val)
      this.page = val
      this.getCrowdList()
    },
    getCrowdList() {
      const param = {}
      param.venueId = sessionStorage.getItem('venueId')
      param.startTime = this.date
      param.type = this.checkedStatus
      crowdedAllCount({
        pagination: {
          firstQueryTime: parseTime(new Date()),
          page: this.page,
          rows: 10
        },
        param
      }).then(res => {
        this.list = res.recordList
        this.total = res.totalCount
      })
    },
    clear() {
      this.checkedStatus = '1'
      this.page = 1
      this.totalCount = 10
      this.getCrowdList()
    },
    search() {
      this.page = 1
      this.totalCount = 10
      this.getCrowdList()
    },
    cancel() {
      this.dialogTableVisible = false
    }
  }
}
</script>

<style lang="scss" scoped>
.footer-style {
  display: flex;
  justify-content: space-between;
  background-color: #f2f2f2;
  margin: -10px -20px -30px;
  height: 50px;
  .bottom-left {
    margin-left: 20px;
    height: 20px;
    margin-top: 15px;
    .sum-title-style {
      font-size: 15px;
      color: #222;
    }
    .sum-pay-value-style {
      font-size: 17px;
      font-weight: 500;
      color: #DD0707;
    }
    .dis-title-style {
      font-size: 14px;
      color: #222;
    }
    .discoun-style {
      font-size: 16px;
      color: #DD0707;
    }
  }
  .bottom-right {
    margin-right: 20px;
    margin-top: 10px;
    height: 30px;
    .pay-action-style {
      width: 100px;
      height: 30px;
      font-size: 15px;
      line-height: 1px;
      vertical-align: middle
    }
  }
}

</style>

<style lang="scss">
.doumee-filter{
  margin-top: 10px;
}
</style>
